using System;
using System.Collections.Generic;
using System.Text;
using SDMX_ML.Framework.Common;
//using SDMX_Element = SDMX_ML.Framework.ElementType;

namespace SDMX_ML.Framework.Structure
{
    /// <summary>
    /// CodelistType.
    /// </summary>
    public class CodelistType
    {
        private List<CodeType> _codevalues;
        private List<TextType> _name;
        private List<TextType> _description;
        private AnnotationsType _annotations;
        private string _id;
        private string _agencyid;
        private string _uri;
        private string _urn; 
        private bool? isExternalReference;
        private bool? isFinal;
        private TimePeriodType _validFrom;
        private TimePeriodType _validTo;
        private string _version;

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="id">Codelist id.</param>
        /// <param name="agencyID">Agency for the codelist</param>
        /// <param name="name">Name of codelist.</param>
        public CodelistType(string id, string agencyID, TextType name)
        {
            _name = new List<TextType>();
            _codevalues = new List<CodeType>();
            _description = new List<TextType>();

            if (!String.IsNullOrEmpty(id) & !String.IsNullOrEmpty(agencyID) & name != null)
            {
                _id = id;
                _agencyid = agencyID;
                _name.Add(name);
            }
            else
            {
                throw new Exception("id, agencyID and name are required fields for a codelist.");
            }
        }

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="id">Codelist id.</param>
        /// <param name="agencyID">Agency for the codelist</param>
        public CodelistType(string id, string agencyID)
        {
            _name = new List<TextType>();
            _codevalues = new List<CodeType>();
            _description = new List<TextType>();

            if (!String.IsNullOrEmpty(id) & !String.IsNullOrEmpty(agencyID))
            {
                _id = id;
                _agencyid = agencyID;
            }
            else
            {
                throw new Exception("id, agencyID are required fields for a codelist.");
            }
        }

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="id">Codelist id.</param>
        /// <param name="agencyID">Agency for the codelist</param>
        /// <param name="name">Name of codelist.</param>
        public CodelistType(string id, string agencyID, string name)
        {
            _name = new List<TextType>();
            _codevalues = new List<CodeType>();
            _description = new List<TextType>();

            if (!String.IsNullOrEmpty(id) & !String.IsNullOrEmpty(agencyID) & !String.IsNullOrEmpty(name))
            {
                _id = id;
                _agencyid = agencyID;
                TextType codelistName = new TextType(name);
                _name.Add(codelistName);
            }
            else
            {
                throw new Exception("id, agencyID and name are required fields for a codelist.");
            }
        }

        /// <summary>
        /// Name(s) of codelist.
        /// </summary>
        public List<TextType> Name
        {
            get { return _name; }
            set { _name = value; }
        }

        /// <summary>
        /// Description of codelist.
        /// </summary>
        public List<TextType> Description
        {
            get { return _description; }
            set { _description = value; }
        }

        /// <summary>
        /// Annotations.
        /// </summary>
        public AnnotationsType Annotations
        {
            get { return _annotations; }
            set { _annotations = value; }
        }

        /// <summary>
        /// Codevalues.
        /// </summary>
        public List<CodeType> Codevalues
        {
            get { return _codevalues; }
            set { _codevalues = value; }
        }

        /// <summary>
        /// Ientification of codelist.
        /// </summary>
        public string Id
        {
            get { return _id; }
            set { _id = value; }
        }

        /// <summary>
        /// AgencyID of owner of codelist.
        /// </summary>
        public string Agencyid
        {
            get { return _agencyid; }
            set { _agencyid = value; }
        }
        
        /// <summary>
        /// Uri.
        /// </summary>
        public string Uri
        {
            get { return _uri; }
            set { _uri = value; }
        }

        /// <summary>
        /// Urn.
        /// </summary>
        public string Urn
        {
            get { return _urn; }
            set { _urn = value; }
        }

        /// <summary>
        /// IsExternal Reference.
        /// </summary>
        public bool? IsExternalReference
        {
          get { return isExternalReference; }
          set { isExternalReference = value; }
        }

        /// <summary>
        /// Is final.
        /// </summary>
        public bool? IsFinal
        {
          get { return isFinal; }
          set { isFinal = value; }
        }

        /// <summary>
        /// Valid from.
        /// </summary>
        public TimePeriodType ValidFrom
        {
            get { return _validFrom; }
            set { _validFrom = value; }
        }

        /// <summary>
        /// Valid to.
        /// </summary>
        public TimePeriodType ValidTo
        {
            get { return _validTo; }
            set { _validTo = value; }
        }

        /// <summary>
        /// Version.
        /// </summary>
        public string Version
        {
            get { return _version; }
            set { _version = value; }
        }

    }
}
